package com.zs.games.controller;

import com.zs.games.entity.UserInfo;
import com.zs.games.param.UserLoginParam;
import com.zs.games.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.zs.games.resultTool.CimResponse;
import com.zs.games.vo.LoginUserVo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 
 * @date 2023年05月09日 17:26
 */
@RestController
@RequestMapping("/auth")
@Api(value = "登陆注册模块", tags = "登陆注册模块")
public class LoginController {
    @Autowired
    private UserInfoService userInfoService;

    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "登陆接口", notes = "登陆接口")
    @PostMapping("/login")
    public CimResponse<LoginUserVo> login(@RequestBody UserLoginParam param){
        return CimResponse.okData(userInfoService.getLoginUserInfo(param.getUserName(), param.getPassword()));
    }
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "注册接口", notes = "注册用户接口")
    @PostMapping("/register")
    public CimResponse<Boolean> register(@RequestBody UserInfo param){
        return CimResponse.okData(userInfoService.save(param));
    }

    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "退出登陆", notes = "退出登陆")
    @PostMapping("/logOut")
    public CimResponse<Boolean> logOut(){
        return CimResponse.okData(userInfoService.logOut());
    }



    
}
